package moxing;

import gonggong.Message;
import gongju.Glxc;
import moshi.Xianchengbaioshi;

import javax.swing.*;
import java.awt.*;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;

public class clientrec extends Thread{
    private String userId;
    private JTextArea mesArea;
    private Socket s;

    public clientrec(Socket s, JTextArea mesArea) {
        this.mesArea = mesArea;
        this.s = s;
    }

    public JTextArea getMesArea() {
        return mesArea;
    }

    public void setMesArea(JTextArea mesArea) {
        this.mesArea = mesArea;
    }

    public Socket getS() {
        return s;
    }

    public void setS(Socket s) {
        this.s = s;
    }

    @Override
    public void run() {
        while(true){
            try {
                ObjectInputStream ois=new ObjectInputStream(s.getInputStream());
                Message m=(Message)ois.readObject();
                System.out.println(m.getCon());
                mesArea.append(m.getCon());
                ois.close();
            } catch (IOException e) {
                e.printStackTrace();
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            }

        }
    }
}
